﻿using AutomationMLMapper.MVVM_Framework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;

namespace AutomationMLMapper.ViewModels.PaneViewModels
{
    public class PaneViewModel : INotifyPropertyChanged
    {
        public PaneViewModel()
        {           
        }  
      
        #region Title

        private string _title = null;
        public string Title
        {
            get { return _title; }
            set
            {
                if (_title != value)
                {
                    _title = value;
                    OnNotifyPropertyChanged("Title");
                }
            }
        }

        #endregion
               
        #region ContentId

        private string _contentId = null;
        public string ContentId
        {
            get { return _contentId; }
            set
            {
                if (_contentId != value)
                {
                    _contentId = value;
                    OnNotifyPropertyChanged("ContentId");
                }
            }
        }

        #endregion

        #region IsFloating

        private bool _isFloating = false;
        public bool IsFloating
        {
            get { return _isFloating; }
            set
            {
                if (_isFloating != value)
                {
                    _isFloating = value;
                    OnNotifyPropertyChanged("IsFloating");
                }
            }
        }

        #endregion


        #region CloseCommand
        RelayCommand<object> _closeCommand = null;
        public ICommand CloseCommand
        {
            get
            {
                if (_closeCommand == null)
                {
                    _closeCommand = new RelayCommand<object>((p) => OnClose(), (p) => CanClose());
                }

                return _closeCommand;
            }
        }

        private bool CanClose()
        {
            return true;
        }

        private void OnClose()
        {
            AutomationMLMapperViewModel.MainViewModel.RemoveAutomationMLTool(this);
        }
        #endregion


        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// PropertyChange Notification method
        /// </summary>
        /// <param name="propertyName">
        /// The property Name.
        /// </param>
        protected void OnNotifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
